package com.ylr.admin.common.enums;

import com.ylr.base.common.dto.NameValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-05-08 18:05:02
 * className: UriEnum
 * version: 1.0
 * description:
 */
@Getter
@AllArgsConstructor
public enum UriEnum {
    // 默认枚举值
    NULL(null, null),

    /*
        系统接口表字段字典值
     */
    // 接口类型[0-包 1-值]
    PACKET_TYPE(0, "包"), VALUE_TYPE(1, "值"),
    // 校验模式[0-全值匹配 1-模糊匹配]
    EQUALS_MATCH(0, "全值匹配"), LIKE_MATCH(1, "模糊匹配"),
    // 接口标签[0-新增 1-查询 2-修改 3-删除]
    SAVE_LABEL(0, "新增"), SEARCH_LABEL(1, "查询"), UPDATE_LABEL(2, "修改"), DELETE_LABEL(3, "删除"),
    ;

    /**
     * 值
     */
    private final Integer value;

    /**
     * 名称
     */
    private final String name;

    /**
     * 获取’校验模式‘枚举对象
     * 根据枚举值对应枚举对象
     * @param value 枚举值
     * @return 枚举对象
     */
    public static UriEnum getCheckModeEnum(Integer value) {
        if (EQUALS_MATCH.value.equals(value)) {
            return EQUALS_MATCH;
        }
        if (LIKE_MATCH.value.equals(value)) {
            return LIKE_MATCH;
        }
        return NULL;
    }

    /**
     * 获取’接口标签‘枚举对象
     * 根据枚举值对应枚举对象
     * @param value 枚举值
     * @return 枚举对象
     */
    public static UriEnum getLabelEnum(Integer value) {
        if (SAVE_LABEL.value.equals(value)) {
            return SAVE_LABEL;
        }
        if (SEARCH_LABEL.value.equals(value)) {
            return SEARCH_LABEL;
        }
        if (UPDATE_LABEL.value.equals(value)) {
            return UPDATE_LABEL;
        }
        if (DELETE_LABEL.value.equals(value)) {
            return DELETE_LABEL;
        }
        return NULL;
    }

    /**
     * 获取接类型枚举列表
     */
    public static List<NameValue<Integer>> getTypeEnumList() {
        List<NameValue<Integer>> list = new ArrayList<>();
        list.add(new NameValue<>(PACKET_TYPE.name, PACKET_TYPE.value));
        list.add(new NameValue<>(VALUE_TYPE.name, VALUE_TYPE.value));
        return list;
    }

    /**
     * 获取接口标签枚举列表
     */
    public static List<NameValue<Integer>> getCheckModeEnumList() {
        List<NameValue<Integer>> list = new ArrayList<>();
        list.add(new NameValue<>(EQUALS_MATCH.name, EQUALS_MATCH.value));
        list.add(new NameValue<>(LIKE_MATCH.name, LIKE_MATCH.value));
        return list;
    }

    /**
     * 获取接口标签枚举列表
     */
    public static List<NameValue<Integer>> getLabelEnumList() {
        List<NameValue<Integer>> list = new ArrayList<>();
        list.add(new NameValue<>(SAVE_LABEL.name, SAVE_LABEL.value));
        list.add(new NameValue<>(SEARCH_LABEL.name, SEARCH_LABEL.value));
        list.add(new NameValue<>(UPDATE_LABEL.name, UPDATE_LABEL.value));
        list.add(new NameValue<>(DELETE_LABEL.name, DELETE_LABEL.value));
        return list;
    }

}
